package com.nemo.edu.dubbo.service;

import com.nemo.edu.dubbo.dto.StringInfoDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 提供者（provider）的实现类，实现了Dubbo API中定义的接口
 */
@Service("dubboProviderService")
public class DubboProviderServiceImpl implements DubboProviderService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 将字符串翻转
     */
    public String reverseStr(StringInfoDto dto) {
        String originalStr = dto.getOriginalStr();
        String reverseStr = new StringBuilder(dto.getOriginalStr()).reverse().toString();

        logger.debug("Provider被执行 原始字符串：" + originalStr + " 反转字符串：" + reverseStr);
        //翻转字符串
        return reverseStr;
    }

}
